package 笔试.未来;

import org.junit.Test;

import java.util.Arrays;

public class one1 {
    @Test
    public void test() {
        System.out.println(firstMissingPositive(new int[]{-2,-1}));
    }
    public int firstMissingPositive (int[] A) {
        Arrays.sort(A);
        int f=0;int g=0;
        for (int i = 0; i < A.length; i++) {
            if(A[i]>=0){
                f=1;
                g=i;
                break;
            }
        }
        if(f==0)return 1;


        for (int i = g; i < A.length-1; i++) {
            if(A[i]+1!=A[i+1]){
                return A[i]+1;
            }
        }
        return A[A.length-1]+1;
    }
}
